package com.xhui.vimarket.common.utils.list;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * .
 * 
 * @版权：福富软件 版权所有 (c) 2011
 * @author wuyx
 * @version Revision 1.0.0
 * @see:
 * @创建日期：2011-4-6
 * @功能说明：
 */
public final class ListUtil {
    
    /**
     * 私有构造函数.
     */
    private ListUtil() {
    }
    
    /**
     * 将set转换为list.
     * 
     * @param set
     *            Set<Object>
     * @return List<Object>
     * @author wuyx
     */
    public static List toList(Set set) {
        List retList = new ArrayList();
        if (set != null) {
            retList.addAll(set);
        }
        return retList;
    }
    
    /**
     * 将set转换为list.
     * 
     * @param str
     *            String[]
     * @return List<Object>
     * @author chenmh
     */
    public static List strToList(String[] str) {
        List retList = new ArrayList();
        if (str != null && str.length > 0) {
            for (int i = 0; i < str.length; i++) {
                retList.add(str[i]);
            }
        }
        return retList;
    }
    
    /**
     * .
     * 
     * @param lists
     *            List...
     * @return List
     * @author wuyx
     *         2011-4-6 wuyx
     */
    public static List joinList(List... lists) {
        Set retSet = new HashSet();
        if (lists != null && lists.length > 0) {
            for (int i = 0; i < lists.length; i++) {
                if (lists[i] != null) {
                    retSet.addAll(lists[i]);
                }
            }
        }
        return ListUtil.toList(retSet);
    }
    /**
     * 数组转换成列表.
     * @param obj 数组对象
     * @return list
     * @author g.luxb
     *         2011-11-24 g.luxb
     */
    public static List objToList(Object[] obj) {
    	List retList = new ArrayList();
        if (obj != null && obj.length > 0) {
            for (int i = 0; i < obj.length; i++) {
                retList.add(obj[i]);
            }
        }
        return retList;
    }
}
